﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mindfor.Web.Data
{
	/// <summary>
	/// Contains information about one page path level.
	/// </summary>
	public class PagePathItem
	{
		/// <summary>
		/// Gets page id.
		/// </summary>
		public int PageId { get; protected set; }

		/// <summary>
		/// Gets page title on selected language.
		/// </summary>
		public string PageTitle { get; private set; }

		/// <summary>
		/// Gets head title on selected language.
		/// </summary>
		public string HeadTitle { get; private set; }

		/// <summary>
		/// Gets menu title on selected language.
		/// </summary>
		public string MenuTitle { get; private set; }

		/// <summary>
		/// Gets pages action execution information.
		/// </summary>
		public ActionPath ActionPath { get; private set; }

		/// <summary>
		/// Initializes new instance.
		/// </summary>
		/// <param name="pageId">Page identity.</param>
		/// <param name="actionPath">Page action information.</param>
		/// <param name="pageTitle">Page title on selected language.</param>
		/// <param name="headTitle">Page head title on selected language.</param>
		/// <param name="menuTitle">Page menu title on selected language.</param>
		public PagePathItem(int pageId, ActionPath actionPath, string pageTitle, string headTitle = null, string menuTitle = null)
		{
			PageId = pageId;
			ActionPath = actionPath;
			PageTitle = pageTitle;
			HeadTitle = headTitle;
			MenuTitle = menuTitle;
		}

		/// <summary>
		/// Initializes new instance.
		/// </summary>
		/// <param name="pageId">Page identity.</param>
		/// <param name="actionPath">Page action information.</param>
		/// <param name="pageText">PageText to get titles from.</param>
		public PagePathItem(int pageId, ActionPath actionPath, PageText pageText)
		{
			PageId = pageId;
			ActionPath = actionPath;
			if (pageText != null)
			{
				PageTitle = pageText.Title;
				HeadTitle = pageText.HeadTitle;
				MenuTitle = pageText.MenuTitle;
			}
		}
	}
}
